package com.aiyige.page.my.message.notifymessage.sysmessage.adapter;

import android.view.View;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.my.message.notifymessage.sysmessage.model.Operation;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import org.w3c.dom.Text;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OperationAdapter extends BaseQuickAdapter<Operation, OperationAdapter.ViewHolder> {


    public OperationAdapter() {
        super(R.layout.system_message_operation_item, new LinkedList<Operation>());
    }

    @Override
    protected void convert(ViewHolder helper, Operation item) {
        helper.bindData(item);
    }


    public class ViewHolder extends BaseViewHolder {
        Operation data;
        @BindView(R.id.agreeBtn)
        TextView agreeBtn;
        @BindView(R.id.ignoreBtn)
        TextView ignoreBtn;
        @BindView(R.id.hasIgnoredBtn)
        TextView hasIgnoredBtn;
        @BindView(R.id.hasAgreedBtn)
        TextView hasAgreedBtn;
        @BindView(R.id.viewCouponBtn)
        TextView viewCouponBtn;
        @BindView(R.id.viewAuthenticationBtn)
        TextView viewAuthenticationBtn;
        @BindView(R.id.reauthenticationBtn)
        TextView reauthenticationBtn;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
            addOnClickListener(R.id.agreeBtn);
            addOnClickListener(R.id.ignoreBtn);
            addOnClickListener(R.id.hasIgnoredBtn);
            addOnClickListener(R.id.hasAgreedBtn);
            addOnClickListener(R.id.viewCouponBtn);
            addOnClickListener(R.id.viewAuthenticationBtn);
            addOnClickListener(R.id.reauthenticationBtn);
        }

        public void bindData(Operation data) {
            this.data = data;
            agreeBtn.setVisibility(View.INVISIBLE);
            ignoreBtn.setVisibility(View.INVISIBLE);
            hasIgnoredBtn.setVisibility(View.INVISIBLE);
            hasAgreedBtn.setVisibility(View.INVISIBLE);
            viewCouponBtn.setVisibility(View.INVISIBLE);
            viewAuthenticationBtn.setVisibility(View.INVISIBLE);
            reauthenticationBtn.setVisibility(View.INVISIBLE);
            switch (data.getOperationType()) {
                case Operation.OPERATION_TYPE_VIEW_AUTHENTICATION:
                    viewAuthenticationBtn.setVisibility(View.VISIBLE);
                    break;
                case Operation.OPERATION_TYPE_REAUTHENTICATION:
                    reauthenticationBtn.setVisibility(View.VISIBLE);
                    break;
                case Operation.OPERATION_TYPE_VIEW_COUPON:
                    viewCouponBtn.setVisibility(View.VISIBLE);
                    break;
                case Operation.OPERATION_TYPE_AGREED_GUARANTEE:
                    hasAgreedBtn.setVisibility(View.VISIBLE);
                    break;
                case Operation.OPERATION_TYPE_BEAGREED_GUARANTEE:
                    agreeBtn.setVisibility(View.VISIBLE);
                    break;
                case Operation.OPERATION_TYPE_BEINGNORED_GUARANTEE:
                    ignoreBtn.setVisibility(View.VISIBLE);
                    break;
                case Operation.OPERATION_TYPE_IGNORED_GUARANTEE:
                    hasIgnoredBtn.setVisibility(View.VISIBLE);
                    break;
            }
        }
    }
}
